<!DOCTYPE html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml"
      xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>销售目标预测APP</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
          name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--插件样式-->
    <link rel="stylesheet" href="/dist/plugins/select2/select2.min.css">
    <link rel="stylesheet" href="/dist/plugins/fixedTable/fixed-table.css"/>
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=39cd89cd">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=16f1e6f3">
    <style>
        /*.fixed-table-box>.fixed-table_header-wraper {*/
        /*!* overflow:hidden;*!*/
        /*overflow-x:hidden;*/
        /*}*/
        /*.nofix{*/
        /*overflow-y: hidden !important;*/
        /*}*/
        .fixed-table_fixed-left{
            box-shadow:none;
        }
        .table > tbody > tr > td {
            height: 30px;
            max-height: 44px;
            overflow: hidden;
            padding: 0 2px;
        }

        .table > thead > tr > th {
            background: #fff !important;
        }

        tbody {
            font-size: 12px;
        }

        .saveModle {
            width: 500px;
            height: 300px;
            position: fixed;
            top: 50%;
            left: 50%;
            margin-left: -250px;
            margin-top: -150px;
            background: #fff;
            border-radius: 10px;
            z-index: 1978;
            display: none;
            border: 1px solid #cfcfcf;
        }

        .saveModle .top {
            height: 34px;
            line-height: 34px;
            font-size: 14px;
            font-weight: bold;
            color: #333;
            padding-left: 7px;
            border-bottom: 1px solid #cfcfcf;
            background: #fff;
        }

        .saveModle .top .title {
            height: 32px;
            line-height: 32px;
            font-size: 14px;
            font-weight: bold;
            color: #333;
            float: left;
            background: #fff;
        }

        .saveModle .top .btn {
            font-size: 20px;
            width: 34px;
            height: 22px;
            line-height: 12px;
            display: inline-block;
            float: right;
        }

        .saveModle .top .btn:hover {
            color: red;
        }

        .saveModle .saveBtn {
            margin: 0 auto;
            margin-top: 35px;
            display: block;

        }


        .lineOne {
            max-height: 36px;
            line-height: 18px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
        }

        p {
            display: inline-block;
            float: left;
            margin-bottom: 0px;
            line-height: 25px;
            padding-right: 15px;
            color: #228bee;
            font-size: 14px;
        }

        .td-value span.lineOne {
            overflow: hidden;
            text-overflow: ellipsis;
            color: black !important;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            max-height: 48px;
            line-height: 24px;
        }

        .td-value span.lineOne1 {
            overflow: hidden;
            text-overflow: ellipsis;
            color: black !important;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            max-height: 48px;
            line-height: 24px;
        }

        .td-value {
            text-align: left !important;
            vertical-align: middle;
            word-wrap: break-word;
            color: black !important;
        }

        .td-value span {
            display: inline-block;
            overflow: hidden;
            padding-left: 0.06rem;
            word-wrap: break-word;
            color: black !important;
        }

        .fixed-table_body tr td {
            border-right: none;
        }

        .fixed-table_header tr th {
            border-right: none;
            background: yellow;
            font-weight: normal;
            font-size: 12px;
        }


        .description {
            display: flex;
            flex-wrap: wrap;
            justify-content: flex-start;
            width: 244px;
        }

        .title {
            background: #F8F8F8 !important;
        }

        .lineOne span, .lineSpan {
            max-height: 20px;
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
        }

        .text-center td {
            background: #fff;
        }

        .slide-box {
            display: -webkit-box;
            -webkit-overflow-scrolling: touch;
            height: 34px;
            line-height: 34px;
            /*background: #2a8cec;*/
            width: 100%;
            padding-left: 5px;
            position: absolute;
            top: 10px;
            z-index: 999999;
        }

        .content {
            padding: 0px 0px 15px 20px;
            padding-bottom: 0;
        }

        .tbList tr td {
            height: 42px !important;
        }

        .fixed-table-box td {
            position: static;
        }

        .fixed-table-box .fixed-table_body td {
            border-left: 1px solid #cbcbcd;
        }

        html, body, #app {
            padding: 0px;
            margin: 0px;
        }

        .fixed-table-box th {
            position: relative;
            text-align: center;
            height: 36px;
            border: 1px solid #cbcbcd;
        }

        .fixed-table-box th {

        }

        .slide-box {
            display: -webkit-box;
            overflow-x: scroll;
            overflow-y: hidden;
            -webkit-overflow-scrolling: touch;
            height: 45px;
            line-height: 45px;
            background: #2a8cec;
            float: left;
            padding-left: 35px;
            width: 100%;
            position: fixed;
            top: 0;
        }

        .lefts {
            text-align: center;
            color: #2a8cec;
            background-image: url(/dist/img/tabApp.png);
            margin-left: 8px;
            margin-right: 8px;
            font-size: 16px;
            background-size: 100% 100%;
            padding: 10px 15px 15px;
        }

        .rights {
            text-align: center;
            color: #fff;
            font-size: 14px;
            /*border-bottom: 2px solid #f8f8f8;*/
            margin-left: 4px;
            margin-right: 4px;
            margin-top: 3px;
            padding-bottom: 5px;
        }

        .templateStyle {
            box-shadow: 2px 2px 3px #DDDDDD;
            margin-left: 10px;
            margin-right: 10px;
            margin-top: 55px;
        }

        .table {
            max-width: 100%;
            margin-bottom: 0px;
        }
    </style>
</head>
<body>
<section class="content " v-cloak style="padding: 0;" id="app">
    <div class="div-td-content-more"><i></i></div>
    <div class="slide-box" v-if="companyList&&companyList.length>1">
        <div v-for="(item,i) in companyList" class="rights">
                <span :class="selectCompany==i? 'lefts':'rights'" style="height: 30px;"
                      @click="stopAjax();selectCompany=i;getZjlSaleTargetYc(item.id,i)">
                    {{item.name}}
                </span>
        </div>
    </div>
    <div style="height:45px;" v-if="companyList&&companyList.length>1"></div>
    <div style="overflow: hidden;">
        <table class="table table-hover text-center table-striped" style="border: none;">
            <thead>
            <tr>
                <th  class="title">当月目标 {{targetSum}}</th>
                <th class="title">已完成 {{finishSum}}</th>
                <th  class="title">成交总概率 <span style="color: red;">{{scale(allChance)}}%</span></th>
                <th class="title">超75%成交总概率 <span style="color: red;">{{scale(overSevenChance)}}%</span></th>
            </tr>
            </thead>
        </table>
    </div>

    <div >
        <div class="box-body no-padding" style="overflow: auto;" id="scrollDiv">
            <div class="fixed-table-box row-col-fixed ">
                <!-- 表头 start -->
                <div class="fixed-table_header-wraper">
                    <table class="fixed-table_header" cellspacing="0" cellpadding="0" border="0"
                           style="width:100%;">
                        <thead>
                        <tr>
                            <th style="width: 30px" data-fixed="true">
                                序号
                            </th>
                            <th style="width: 55px" data-fixed="true">
                                大区
                            </th>
                            <th style="width: 46px" data-fixed="true">
                                大区<br>经理
                            </th>
                            <th style="width: 80px" data-fixed="true">
                                区域
                            </th>
                            <th style="width:46px" data-fixed="true">
                                区域<br>经理
                            </th>
                            <th style="width: 46px">
                                客户<br>姓名
                            </th>
                            <th style="width: 60px">
                                意向<br>机型
                            </th>
                            <th style="width: 50px">
                                购买<br>时间
                            </th>
                            <th style="width: 60px">
                                预计成交<br>时间
                            </th>
                            <th style="width: 50px;">
                                成交<br>概率
                            </th>
                            <th style="width: 50px;">
                                心里价格<br>(万)
                            </th>
                            <th style="width: 30px;">
                                是否<br>置换
                            </th>
                            <th style="width: 75px;">
                                置换品牌<br>机型
                            </th>
                            <th style="width: 50px;">
                                评估价<br>(万)
                            </th>
                            <th style="width: 60px;">
                                付款<br>方式
                            </th>
                            <th style="width: 50px;">
                                首付<br>比例
                            </th>
                            <th style="width: 50px;">
                                定金<br>状态
                            </th>
                            <th style="width: 50px;">
                                定金金额<br>(万)
                            </th>
                            <th style="width:200px;">
                                最新跟踪
                            </th>
                            <th style="width: 60px;border-right: none">
                                更新状态
                            </th>
                        </tr>
                        </thead>
                    </table>
                </div>
                <!--内容-->
                <div class="fixed-table_body-wraper iframeXSY">
                    <table cellspacing="0" cellpadding="0" border="0"
                           style="width: 100%;border-top-width:0px;" id="tableMain">
                        <tbody class="tbList">
                        <tr v-for="(item,i) in list">
                            <td style="width: 30px;text-align: center;">
                                <div class="table-cell">{{i+1}}</div>
                            </td>
                            <td style="width: 55px;text-align: center;"
                                :rowspan="item.bigManagerRegionNamespan"
                                :class="{hidden: item.bigManagerRegionNamedis}">
                                {{item.bigManagerRegionName.substring(0,item.bigManagerRegionName.length-2)}}<br>大区
                            </td>
                            <td style="width: 46px;text-align: center;"
                                :rowspan="item.bigManagerNamespan"
                                :class="{hidden: item.bigManagerNamedis}">
                                <div class="table-cell">
                                <span class="duiqi">
                                                {{item.bigManagerName}}<i
                                        style="display: inline-block;width: 100%;height: 0;"></i>
                                            </span></div>
                            </td>
                            <td style="width: 80px;text-align: center;"
                                :rowspan="item.managerRegionNamespan"
                                :class="{hidden: item.managerRegionNamedis}">
                                <div class="table-cell" style="height: 36px"><span class="lineOne"
                                                                                   style="text-align: left;"
                                                                                   :style="item.managerRegionName.length>5?'':'line-height:36px'">{{item.managerRegionName}}</span>
                                </div>
                            </td>
                            <td style="width: 46px;text-align: center;"
                                :rowspan="item.managerRegionNamespan"
                                :class="{hidden: item.managerRegionNamedis}">
                                <div class="table-cell">
                                <span class="duiqi">
                                                {{item.managerName}}<i
                                        style="display: inline-block;width: 100%;height: 0;"></i>
                                            </span>
                                </div>
                            </td>
                            <td style="width: 46px;text-align: center;">
                                <div class="table-cell">
                                <span @click="openDetail(item,0)" class="duiqi"
                                      style="color: rgb(42, 140, 236);cursor:pointer;">
                                                {{item.customerName}}<i
                                        style="display: inline-block;width: 100%;height: 0;"></i>
                                            </span></div>
                            </td>
                            <td style="width: 60px;text-align: center;" class="td-value">
                                <div class="table-cell"><span class="lineOne">{{item.intentionModel}}</span>
                                </div>
                            </td>
                            <td style="width: 50px;text-align: center;" class="td-value">
                                <div class="table-cell"><span
                                        class="lineOne1">{{item.buyDate}}</span></div>
                            </td>
                            <td style="width: 60px;text-align: center;" class="td-value">
                                <div class="table-cell"><span
                                        class="lineOne1">{{item.yjOkDate}}</span></div>
                            </td>
                            <td style="width: 50px;text-align: center;" class="td-value">
                                <div class="table-cell"><span
                                        class="lineOne1">{{item.chance}}</span></div>
                            </td>
                            <td style="width: 50px;text-align: center;" class="td-value">
                                <div class="table-cell"><span class="lineOne1">{{item.psychologicalPrice}}</span>
                                </div>
                            </td>
                            <td style="width: 30px;text-align: center;" class="td-value">
                                <div class="table-cell"><span class="lineOne1"
                                                              v-if="item.ifReplace=='1'">是</span>
                                    <span class="lineOne1" v-if="item.ifReplace=='0'">否</span></div>
                            </td>
                            <td style="width: 75px;text-align: center;" class="td-value">
                                <div class="table-cell"><span
                                        class="lineOne">{{item.replaceType}}</span></div>
                            </td>
                            <td style="width: 50px;text-align: center;" class="td-value">
                                <div class="table-cell"><span class="lineOne1">{{item.valuationPrice}}</span>
                                </div>
                            </td>
                            <td style="width: 60px;text-align: center;" class="td-value">
                                <div class="table-cell"><span
                                        class="lineOne1">{{item.buyType}}</span></div>
                            </td>
                            <td style="width: 50px;text-align: center;" class="td-value">
                                <div class="table-cell">        <span class="lineOne1" v-if="item.paymentRatio!=''">{{item.paymentRatio}}%</span>
                                    <span class="lineOne1" v-else></span></div>
                            </td>
                            <td style="width: 50px;text-align: center;" class="td-value">
                                <div class="table-cell"><span class="lineOne1">{{item.earnestStatus}}</span>
                                </div>
                            </td>
                            <td style="width: 50px;text-align: center;" class="td-value">
                                <div class="table-cell"><span
                                        class="lineOne1">{{item.earnestMoney}}</span></div>
                            </td>
                            <td style="width: 200px;">
                                <div class="table-cell" style="height: 36px;"><span class="lineOne"
                                                                                    style="text-align: left">{{item.otherCondition}}</span>
                                </div>
                            </td>
                            <td style="width: 60px;text-align: center;" class="td-value">
                                <div class="table-cell"><span class="lineOne1"
                                                              :style="item.state=='已更新'?'color :red !important;':''">{{item.state}}</span>
                                </div>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
                <!--固定列-->
                <div class="fixed-table_fixed fixed-table_fixed-left">
                    <div class="fixed-table_header-wraper nofix">
                        <table class="fixed-table_header" style="border-right:1px solid #d3e8fd;"
                               cellspacing="0"
                               cellpadding="0" border="0">
                            <thead>
                            <tr>
                                <th style="width: 30px;">
                                    序号
                                </th>
                                <th style="width: 55px">
                                    大区
                                </th>
                                <th style="width: 46px">
                                    大区<br>经理
                                </th>
                                <th style="width: 80px">
                                    区域
                                </th>
                                <th style="width: 46px" style="border-right-width:0px;">
                                    区域<br>经理
                                </th>
                            </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="fixed-table_body-wraper iframeXSYLeft">
                        <table class="fixed-table_body" cellspacing="0" cellpadding="0" border="0"
                               style="border-right:1px solid #cbcbcd;">
                            <tbody class="tbList">
                            <tr v-for="(item,i) in list">
                                <td style="width: 30px;text-align: center;">
                                    <div class="table-cell">{{i+1}}</div>
                                </td>
                                <td style="width: 55px;text-align: center;"
                                    :rowspan="item.bigManagerRegionNamespan"
                                    :class="{hidden: item.bigManagerRegionNamedis}">
                                    {{item.bigManagerRegionName.substring(0,item.bigManagerRegionName.length-2)}}<br>大区
                                </td>
                                <td style="width: 46px;text-align: center;"
                                    :rowspan="item.bigManagerNamespan"
                                    :class="{hidden: item.bigManagerNamedis}">
                                    <div class="table-cell">
                                <span class="duiqi">
                                                {{item.bigManagerName}}<i
                                        style="display: inline-block;width: 100%;height: 0;"></i>
                                            </span></div>
                                </td>
                                <td style="width: 80px;text-align: center;"
                                    :rowspan="item.managerRegionNamespan"
                                    :class="{hidden: item.managerRegionNamedis}">
                                    <div class="table-cell" style="height: 36px"><span
                                            class="lineOne" style="text-align: left;"
                                            :style="item.managerRegionName.length>5?'':'line-height:36px'">{{item.managerRegionName}}</span>
                                    </div>
                                </td>
                                <td style="width: 46px;text-align: center;"
                                    :rowspan="item.managerRegionNamespan"
                                    :class="{hidden: item.managerRegionNamedis}">
                                    <div class="table-cell">
                                <span class="duiqi">
                                                {{item.managerName}}<i
                                        style="display: inline-block;width: 100%;height: 0;"></i>
                                            </span>
                                    </div>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!--公司列表-->

</section>
<!--JQ-->
<script src="/dist/plugins/jQuery/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oaApp.js"></script>
<script type="text/javascript" src="/dist/plugins/vue/vue.js"></script>
<script src="/dist/plugins/fixedTable/fixed-table.js"></script>
<script>
    $.ajaxSetup({
        global: true,
        type: "POST",
        cache: false,
        dataType: "json",
        contentType: 'application/json;charset=utf-8',
        beforeSend: function () {
        },
        complete: function () {
            JSBridge.call(UI, 'hideLoading', {});
        },
        error: function (e) {
            JSBridge.call(UI, 'showToast', {title: e.responseText});
        }
    });
    $.extend($.wyui, {
        postMethod: function (url, data, callback, sync, id) {
            if (!id) {
                id = "#app"
            }
            $.ajax({
                url: server.ip + url,
                async: sync ? false : true,
                data: JSON.stringify(data),
                beforeSend: function () {

                },
                complete: function () {
                    setTimeout(function () {
                    }, 1000);

                },
                success: function (r) {
                    if (!r.e.code) {
                        callback(r.data.sendData);
                    } else {
                        JSBridge.call(UI, 'showToast', {title: r.e.desc});
                    }
                },
                error: function (e) {
                    JSBridge.call(UI, 'showToast', {title: e.responseText});
                }
            });
        },
    });
</script>
<script>
    $(function () {
        $("body").on("click", ".lineOne,.lineTwo", function (e) {
            if ($(".div-td-content-more").is(":hidden")) {
                var text = $(this).text();
                if (text != "") {
                    text = "<i></i>" + text;
                    $(".div-td-content-more").html(text).css({
                        "width": $(this).outerWidth() + 12 + "px",
                        "left": $(this).offset().left - 6,
                        "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                    }).show();
                    e.stopPropagation();
                }
            } else {
                $(".div-td-content-more").hide();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });
</script>
<script>
    $.xhrPool = [];
    $.xhrPool.abortAll = function () {
        $(this).each(function (idx, jqXHR) {
            console.log(idx, jqXHR);
            jqXHR.abort();
        });
        $.xhrPool = [];
    };
</script>
<script type="text/javascript">
    function refresh() {
        $.wyui.page.getByPage();
    }

    var app = new Vue({
            el: '#app',
            data: {
                selectCompany: 0,
                userId: getUrlParamObj().userId,
                targetSum: 0,
                finishSum: 0,
                allChance: 0,
                overSevenChance: 0,
                keyYc: '',
                buyDateYc: '',
                companyId: '',
                index: 0,
                list: [],
                selectCompany: 0,
                companyList: [],
                buyDateObj: {},
            },
            methods: {
                stopAjax: function () {
                    if ($.xhrPool && $.xhrPool.length > 0) {
                        $.xhrPool.abortAll();
                        $.xhrPool.abortAll = function () {
                            $(this).each(function (idx, jqXHR) {
                                console.log(idx, jqXHR);
                                jqXHR.abort();
                            });
                            $.xhrPool = [];
                        };
                    } else {
                        console.log("没有需要关闭的ajax")
                    }
                },
                getUserRoleName: function () {
                    var that = this;
                    $.wyui.postMethod("/newAppReportForZSQ/getRoleNameByUserId.json", {
                        "userId": that.userId,
                    }, function (data) {
                        var roleName = data.records;
                        if (roleName && roleName != '') {
                            if (roleName == '大区经理') {
                                // "daQuList.html
                                //that.getBigRegionSaleTargetYc()
                                that.getCompanyList()
                                var H = $(window).height()
                                $(".iframeXSY").height(H - 66);
                                $(".iframeXSYLeft").height(H - 66);
                            } else {
                                //managerList.html
                                that.getCompanyList()
                                var H = $(window).height()
                                $(".iframeXSY").height(H - 109);
                                $(".iframeXSYLeft").height(H - 109);
                            }
                        }
                    });
                },
                getBigRegionSaleTargetYc: function () {
                    var that = this;
                    JSBridge.call(UI, 'showLoading', {})
                    $.ajax({
                        url: server.ip + '/depConfig/getBigRegionSaleTargetYc.json',
                        contentType: 'application/json;charset=utf-8',
                        type: "POST",
                        data: JSON.stringify({
                            userId: that.userId,
                            date: that.getNowDate(),
                            keyYc: that.keyYc,
                            buyDateYc: that.buyDateYc
                        }),
                        success: function (r) {
                            var r = r.data.sendData
                            that.allChance = 0;
                            that.overSevenChance = 0;
                            for (var i = 0; i < r.result.length; i++) {
                                var chanceNum = r.result[i].chance.length - 1;
                                if (r.result[i].buyDate == '本月内') {
                                    if (r.result[i].chance != '<50%') {
                                        that.allChance = that.allChance + Number(r.result[i].chance.substring(0, chanceNum))
                                    }
                                    console.log(Number(r.result[i].chance.substring(0, chanceNum)))
                                    if (Number(r.result[i].chance.substring(0, chanceNum)) >= 75) {
                                        that.overSevenChance = that.overSevenChance + Number(r.result[i].chance.substring(0, chanceNum))
                                    }
                                }
                                /* r.result[i].todayOtherCondition = '';
                                 r.result[i].yesterdayOtherCondition = '';*/
                                r.result[i].state = '';
                            }
                            //console.log(that.allChance, that.overSevenChance)

                            that.list = that.tablesMergeCell(r.result);
                            if (that.list && that.list.length > 0) {
                                for (var i = 0; i < that.list.length; i++) {
                                    //that.getCustomerVisit(i);
                                    that.isToday(i);
                                }
                            }
                            that.finishSum = r.targetSale.finishSum;
                            that.targetSum = Number(r.targetSale.saleTarget);
                        },
                    })
                },
                getCompanyList: function () {
                    var that = this
                    $.wyui.postMethod('/company/getCompanyListByUserIdAndRegionId.json', {
                        "userId": that.userId,
                    }, function (r) {
                        if (r && r.length > 0) {
                            for (var i = 0; i < r.length; i++) {
                                if (r[i].id && r[i].id != '201712161613432EAF27DBCCB7D0E6CA' && r[i].id != '2019011814474FCDB1FC400060A3BEBF') {
                                    that.companyList.push(r[i]);
                                }
                            }
                        }
                        if (that.companyList && that.companyList.length > 0) {
                            var companyId = that.companyList[0].id;
                            that.getZjlSaleTargetYc(companyId);
                        }
                    })
                },
                getBuyDate: function () {
                    var that = this
                    $.wyui.postMethod('/enum2/selectByModuleType.json', {moduleType: 'buyDate'}, function (r) {
                        var list = r;
                        that.buyDateList = r;
                        if (list && list.length > 0) {
                            that.buyDateObj = new Map();
                            for (var i = 0; i < list.length; i++) {
                                var k = list[i].key;
                                var v = list[i].value;
                                that.buyDateObj.set(k, v);
                            }
                        }
                    });
                },
                tablesMergeCell: function (list) {
                    for (field in list[0]) {
                        var k = 0;
                        while (k < list.length) {
                            list[k][field + 'span'] = 1;
                            list[k][field + 'dis'] = false;
                            for (var i = k + 1; i <= list.length - 1; i++) {
                                if (list[k][field] == list[i][field] && list[k][field] != '' || list[k][field] == 0 && list[i][field] == 0) {
                                    if (field == 'childRegionName') {
                                        if (list[k].regionName == list[i].regionName) {
                                            list[k][field + 'span']++;
                                            list[k][field + 'dis'] = false;
                                            list[i][field + 'span'] = 1;
                                            list[i][field + 'dis'] = true;
                                        }
                                    } else if (field == 'quyuName') {
                                        if (list[k].regionName == list[i].regionName && list[k].childRegionName == list[i].childRegionName) {
                                            list[k][field + 'span']++;
                                            list[k][field + 'dis'] = false;
                                            list[i][field + 'span'] = 1;
                                            list[i][field + 'dis'] = true;
                                        }
                                    } else {
                                        list[k][field + 'span']++;
                                        list[k][field + 'dis'] = false;
                                        list[i][field + 'span'] = 1;
                                        list[i][field + 'dis'] = true;
                                    }
                                } else {
                                    break;
                                }
                            }
                            k = i;
                        }
                    }
                    return list;
                },
                openDetail: function (item, isAdd) {
                    var that = this;
                    var param = {
                        url: '/page/intentionManagement/quYuIntentionalDetailApp.html?customerId=' + item.customerId + '&isAdd=' + isAdd + '&pageType=edit&userId=' + that.userId + '&companyId=' + that.companyId + '&isRegion=1&isRegion=1&type=',
                        enableRefresh: false,   //是否启用下拉刷新
                    }
                    JSBridge.call(ROUTER, 'navigateTo', param)
                },
                isToday: function (i) {
                    var that = this;
                    var item = that.list[i];
                    if (!item.customerId || item.customerId == '') {
                        that.list[i].state = '';
                    } else {
                        if (item.createTime && item.createTime != '') {
                            if (item.createTime.substring(0, 10) == this.getNowDate()) {
                                that.list[i].state = "今日新增"
                            } else {
                                if (item.updateTime && item.updateTime != '' && item.updateTime.substring(0, 10) == this.getNowDate()) {
                                    var intentionFlag = 0;
                                    $.ajax({
                                        url: server.ip + '/depConfig/getIntentCustomerState.json',
                                        contentType: 'application/json;charset=utf-8',
                                        type: "POST",
                                        data: JSON.stringify({
                                                userId: item.managerId,
                                                customerId: item.customerId,
                                                dateTime: that.getNowDate()
                                            }
                                        ),
                                        beforeSend: function (jqXHR) {
                                            $.xhrPool.push(jqXHR);
                                        }, complete: function (jqXHR) {
                                            var index = $.xhrPool.indexOf(jqXHR);
                                        },
                                        error: function () {
                                            console.log('error')
                                        },
                                        success: function (r) {
                                            var r = r.data.sendData
                                            intentionFlag = r.intentionFlag;
                                            if (intentionFlag == 0) {
                                                that.list[i].state = '今日新增';
                                            } else {
                                                that.list[i].state = '已更新';
                                            }
                                        },
                                    })

                                } else {
                                    that.list[i].state = "未更新"
                                }
                            }
                        }
                    }
                },
                getNowDate: function () {
                    var now = new Date();
                    var year = now.getFullYear();
                    var month = (now.getMonth() + 1).toString();
                    var day = (now.getDate()).toString();
                    var hour = (now.getHours()).toString();
                    var minute = (now.getMinutes()).toString();
                    var second = (now.getSeconds()).toString();
                    if (month.length == 1) {
                        month = "0" + month;
                    }
                    if (day.length == 1) {
                        day = "0" + day;
                    }
                    if (hour.length == 1) {
                        hour = "0" + hour;
                    }
                    if (minute.length == 1) {
                        minute = "0" + minute;
                    }
                    if (second.length == 1) {
                        second = "0" + second;
                    }
                    var dateTime = year + "-" + month + "-" + day;
                    return dateTime;
                },
                getCustomerVisit: function (index) {
                    var that = this;
                    var item = that.list[index];
                    if (!item.customerId || item.customerId == '') {
                        item.todayOtherCondition = '';
                        item.yesterdayOtherCondition = '';
                    } else {
                        $.ajax({
                            url: server.ip + '/depConfig/getCustomerVisit.json',
                            contentType: 'application/json;charset=utf-8',
                            type: "POST",
                            data: JSON.stringify({
                                    createUserId: item.childRegionId,
                                    customerId: item.customerId
                                }
                            ),
                            beforeSend: function (jqXHR) {
                                $.xhrPool.push(jqXHR);
                            }, complete: function (jqXHR) {
                                var index = $.xhrPool.indexOf(jqXHR);
                                if (index > -1) {
                                    $.xhrPool.splice(index, 1);
                                }
                            },
                            error: function () {
                                console.log('error')
                            },
                            success: function (r) {
                                var r = r.data.sendData
                                that.list[index].todayOtherCondition = r.result.todayOtherCondition;
                                that.list[index].yesterdayOtherCondition = r.result.yesterdayOtherCondition;
                            },
                        })

                    }
                },
                showBuyDate: function (item) {
                    var that = this;
                    var buyDate = item.buyDate;
                    return that.buyDateObj.get(buyDate);
                },
                scale: function (num) {
                    var that = this;
                    if ((Number(that.targetSum) - Number(that.finishSum)) == 0) {
                        return 0
                    } else {
                        console.log(Number(num), (Number(that.targetSum) - Number(that.finishSum)))

                        return (Number(num) / (Number(that.targetSum) - Number(that.finishSum))).toFixed(2)

                    }
                },
                getZjlSaleTargetYc: function (companyId, i) {
                    console.log(companyId)
                    var that = this;
                    that.companyId = companyId;
                    that.index = i
                    console.log(that.companyId)
                    if (i) {
                        that.selectCompany = i;
                        //jquery.ajax().abort;
                    } else {
                        that.selectCompany = 0;
                    }
                    JSBridge.call(UI, 'showLoading', {})
                    $.ajax({
                        url: server.ip + '/depConfig/getZjlSaleTargetYc.json',
                        contentType: 'application/json;charset=utf-8',
                        type: "POST",
                        data: JSON.stringify({
                                userId: that.userId,
                                date: that.getNowDate(),
                                companyId: companyId,
                                keyYc: that.keyYc,
                                buyDateYc: that.buyDateYc
                            }
                        ),
                        success: function (r) {
                            var r = r.data.sendData
                            that.allChance = 0;
                            that.overSevenChance = 0;
                            for (var i = 0; i < r.result.length; i++) {
                                var chanceNum = r.result[i].chance.length - 1
                                console.log(r.result[i].chance.substring(0, chanceNum))
                                if (r.result[i].buyDate == '本月内') {
                                    if (r.result[i].chance != '<50%') {
                                        that.allChance = that.allChance + Number(r.result[i].chance.substring(0, chanceNum))
                                    }
                                    if (Number(r.result[i].chance.substring(0, chanceNum)) >= 75) {
                                        that.overSevenChance = that.overSevenChance + Number(r.result[i].chance.substring(0, chanceNum))
                                    }
                                }
                                /*  r.result[i].todayOtherCondition = '';
                                  r.result[i].yesterdayOtherCondition = '';*/
                                r.result[i].state = '';
                            }
                            console.log(that.allChance, that.overSevenChance)
                            for (var i=0;i<r.result.length;i++){
                                for (var j=0;j<r.result.length;j++){
                                    //当区域不为空，并且区域经理为空，前边出现就删掉他
                                    if (r.result[i].managerRegionName.indexOf(r.result[j].managerRegionName)!=-1&&r.result[j].managerRegionName!=''&&r.result[j].managerName==''){
                                        r.result.splice(j,1)
                                    }
                                }
                            }
                            that.list = that.tablesMergeCell(r.result);
                            if (that.list && that.list.length > 0) {
                                for (var i = 0; i < that.list.length; i++) {
                                    //that.getCustomerVisit(i);
                                    that.isToday(i);
                                }
                            }
                            that.finishSum = r.targetSale.finishSum;
                            that.targetSum = Number(r.targetSale.saleTarget);
                        },
                    })

                },
            },
            mounted: function () {
                var that = this
                that.getUserRoleName()
                that.getBuyDate()
            }
        })
    ;
</script>
<script>
    $(".fixed-table-box").fixedTable();
</script>
<script>

</script>
</body>
</html>